package com.mediacloud.app.newsmodule.view

import android.view.View
import androidx.core.content.ContextCompat
import com.mediacloud.app.assembly.util.load
import com.mediacloud.app.newsmodule.R
import com.mediacloud.app.newsmodule.utils.load
import com.mediacloud.app.reslib.databinding.LibRequestLoadingLayoutBinding
import com.mediacloud.app.reslib.enums.AppFactoryGlobalConfig

fun LibRequestLoadingLayoutBinding.closeLoading()
{
    root.visibility=View.GONE
    progressBar.visibility= View.GONE
    imageLoading.visibility=View.GONE
}

fun LibRequestLoadingLayoutBinding.addClickListener(call:()->Unit)
{
    root.setOnClickListener {
        call.invoke()
    }
}

fun LibRequestLoadingLayoutBinding.showLoading()
{
    root.visibility=View.VISIBLE
    progressBar.visibility= View.VISIBLE
    imageLoading.visibility=View.GONE
}

fun LibRequestLoadingLayoutBinding.showNoContent()
{
    root.visibility=View.VISIBLE
    progressBar.visibility= View.GONE
    imageLoading.visibility=View.VISIBLE
    ContextCompat.getDrawable(root.context, R.drawable.no_content)?.let { imageLoading.load(AppFactoryGlobalConfig.getAppServerConfigInfo(root.context).noContent, it) }
    //GlideUtils.loadUrl(AppFactoryGlobalConfig.getAppServerConfigInfo(root.context).noContent,imageLoading,null,ContextCompat.getDrawable(root.context, R.drawable.no_content))
}

fun LibRequestLoadingLayoutBinding.showNetError()
{
    root.visibility=View.VISIBLE
    progressBar.visibility= View.GONE
    imageLoading.visibility=View.VISIBLE
    ContextCompat.getDrawable(root.context, R.drawable.net_not_give_force)?.let { imageLoading.load(AppFactoryGlobalConfig.getAppServerConfigInfo(root.context).network, it) }
   // GlideUtils.loadUrl(AppFactoryGlobalConfig.getAppServerConfigInfo(root.context).network,imageLoading,null,ContextCompat.getDrawable(root.context, R.drawable.net_not_give_force))
}